<%--
    Document   : index
    Created on : 9 mai 2012, 11:34:29
    Author     : Thomas
--%>

<%@include file="_header.jsp" %>
<%@include file="_left.jsp" %>

<%! String error_msg; %>
<% error_msg = (String)request.getAttribute("error_msg"); %>

<%! List<Product> products; %>
<% products = (List<Product>) request.getAttribute("products"); %>

<div class="span7">
<% if (error_msg != null) { %>
    <h3>Oups !</h3>
    <br/>
    <div class="alert-error"><strong><%= error_msg %></strong></div>
    <hr/>
    <div class="row-fluid">
        <div class="pull-right">
            <a class="btn btn-primary" href="<%= request.getContextPath() %>">OK</a>
        </div>
    </div>
<% } else if(products.isEmpty()) { %>
    <h3>Oups !</h3>
    <br/>
    <div class="alert-error"><strong>Aucun produit trouv&eacute; dans cette cat&eacute;gorie (<em>"<%= request.getAttribute("categoryName").toString() %>"</em>)</strong></div>
<% } else { %>
    <h3><%= request.getAttribute("categoryName").toString() %></h3>
    <table class="table">
        <thead>
            <tr>
                <th>Produit</th>
                <th>Prix</th>
                <th>Stock</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
        <% for(Product product : products) {%>
            <tr>
                <td><a href="<%= request.getContextPath() %>/Index?action=voirProduit&productID=<%= product.getID() %>"><%= product.getName() %></a></td>
                <td style="text-align: right;"><%= product.getPrice() %>&nbsp;&euro;</td>
                <td style="text-align: right;"><%= product.getStock() %></td>
                <% if (product.getStock() > 0) {%>
                <td style="text-align: right;"><a href="<%= request.getContextPath() %>/Basket?action=ajouterProduit&productID=<%= product.getID() %>"><i class="icon-plus-sign" title="Cliquez pour ajouter ce produit au panier"></i></a></td>
                <% } else { %>
                <td style="text-align: right; color: RED;">rupture</td>
                <% } %>
            </tr>
        <% }%>
        </tbody>
    </table>
<% } %>
</div>

<%@include file="_right.jsp" %>
<%@include file="_footer.jsp" %>